package controllers

import (
	"fs_oms/models"
	"github.com/astaxie/beego"
)

type DelGatewayController struct {
	beego.Controller
}

func (c *DelGatewayController) Get() {
	c.TplName = "delgateway.tpl"
}

func (c *DelGatewayController) Post() {
	var name = c.GetString("name")
	if !models.IsGatewayExist(name) {
		c.Data["result"] = "网关" + name + "不存在!"
	} else {
		err := models.DelGateway(name)
		if err != nil {
			c.Data["result"] = "删除网关" + name + "失败!"
		} else {
			models.SyncData()
			c.Data["result"] = "删除网关" + name + "成功!"
		}
	}

	c.TplName = "delsub_result.tpl"
}
